package com.baizhi.service.impl;

import com.baizhi.entity.CmfzAdmin;
import com.baizhi.mapper.CmfzAdminMapper;
import com.baizhi.service.CmfzAdminService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * InnoDB free: 11264 kB 服务实现类
 * </p>
 *
 * @author xiaoxiao
 * @since 2020-08-18
 */
@Service
public class CmfzAdminServiceImpl extends ServiceImpl<CmfzAdminMapper, CmfzAdmin> implements CmfzAdminService {

    @Override
    public CmfzAdmin login(CmfzAdmin cmfzAdmin) {
        //通过姓名查是否存在
        QueryWrapper<CmfzAdmin> qw = new QueryWrapper<>();
        qw.eq("username", cmfzAdmin.getUsername());
        CmfzAdmin cmfzAdmin1 = baseMapper.selectOne(qw);
        //若不为空且密码相同,则存在
        if(cmfzAdmin1 != null && cmfzAdmin.getPassword().equals(cmfzAdmin1.getPassword())){
            return cmfzAdmin1;
        }
        return null;
    }
}
